import request from "./request.js";
import proxyRequest from "./proxyRequest.js";

// 设置当前request请求的 请求前缀
// 后端支持跨域
request.defaults.baseURL = "http://127.0.0.1:3000/public/"; 
// 后端不支持跨域 - 代理服务器运行
// proxyRequest.defaults.baseURL = "http://127.0.0.1:3000/api/";

// proxyRequest.defaults.baseURL = "http://127.0.0.1:8080/proxy/api/";
// proxyRequest.defaults.baseURL = "/proxy/api/";
// proxyRequest.defaults.baseURL = process.env.NODE_ENV=="development"?"/proxy/api/":"/api/";

// 基于启动方式和环境文件
proxyRequest.defaults.baseURL = process.env.VUE_APP_REQUEST_URL;

export const loadTypes = function(){
    return request.get("types")
}

export const loadProxyTypes = function(){
    return proxyRequest.get("types")
}

export const loadFilms = function(params={}){
    return request.get("films",{
        // params:params
        params
    })
}

export const loadProxyFilms = function(params={}){
    return proxyRequest.get("films",{
        // params:params
        params
    })
}

export default {
    loadTypes,loadFilms,
    loadProxyTypes,loadProxyFilms
}
